home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Think-Pascal-7.0.cpt / THINK Pascal Interfaces / Printing.p < prev    next >
Encoding:
Text File  |  1991-04-05  |  9.7 KB  |  339 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.    }
  2.  
  3. {
  4. Created: Sunday, January 6, 1991 at 10:57 PM
  5.     Printing.p
  6.     Pascal Interface to the Macintosh Libraries
  7.  
  8.         Copyright Apple Computer, Inc.    1985-1989
  9.         All rights reserved
  10.  
  11. }
  12.  
  13.  
  14. {$IFC UNDEFINED UsingIncludes}
  15. {$SETC UsingIncludes := 0}
  16. {$ENDC}
  17.  
  18.  
  19.     UNIT Printing;
  20.     INTERFACE
  21.     USES
  22.         Types, Quickdraw, Dialogs;
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. CONST
  40. iPFMaxPgs = 128;
  41. iPrPgFract = 120;                       {Page scale factor. ptPgSize (below) is in units of 1/iPrPgFract}
  42. iPrPgFst = 1;                           {Page range constants}
  43. iPrPgMax = 9999;
  44. iPrRelease = 3;                         {Current version number of the code.}
  45. iPrSavPFil = -1;
  46. iPrAbort = $0080;
  47. iPrDevCtl = 7;                          {The PrDevCtl Proc's ctl number}
  48. lPrReset = $00010000;                   {The PrDevCtl Proc's CParam for reset}
  49. lPrLineFeed = $00030000;
  50. lPrLFStd = $0003FFFF;                   {The PrDevCtl Proc's CParam for std paper advance}
  51. lPrLFSixth = $0003FFFF;
  52. lPrPageEnd = $00020000;                 {The PrDevCtl Proc's CParam for end page}
  53. lPrDocOpen = $00010000;
  54. lPrPageOpen = $00040000;
  55. lPrPageClose = $00020000;
  56. lPrDocClose = $00050000;
  57. iFMgrCtl = 8;                           {The FMgr's Tail-hook Proc's ctl number}
  58. iMemFullErr = -108;
  59. iIOAbort = -27;
  60. pPrGlobals = $00000944;                 {The PrVars lo mem area:}
  61. bDraftLoop = 0;
  62. bSpoolLoop = 1;
  63. bUser1Loop = 2;
  64. bUser2Loop = 3;
  65. iPrBitsCtl = 4;
  66. lScreenBits = 0;
  67. lPaintBits = 1;
  68. lHiScreenBits = $00000002;              {The Bitmap Print Proc's Screen Bitmap param}
  69. lHiPaintBits = $00000003;               {The Bitmap Print Proc's Paint [sq pix] param}
  70. iPrIOCtl = 5;
  71. iPrEvtCtl = 6;                          {The PrEvent Proc's ctl number}
  72. lPrEvtAll = $0002FFFD;                  {The PrEvent Proc's CParam for the entire screen}
  73. lPrEvtTop = $0001FFFD;                  {The PrEvent Proc's CParam for the top folder}
  74. iPrDrvrRef = -3;
  75. getRslDataOp = 4;
  76. setRslOp = 5;
  77. draftBitsOp = 6;
  78. noDraftBitsOp = 7;
  79. getRotnOp = 8;
  80. NoSuchRsl = 1;
  81. RgType1 = 1;
  82.  
  83. TYPE
  84. TFeed = (feedCut,feedFanfold,feedMechCut,feedOther);
  85.  
  86. TScan = (scanTB,scanBT,scanLR,scanRL);
  87.  
  88.  
  89. TPRect = ^Rect;                         { A Rect Ptr }
  90.  
  91.  
  92. PrIdleProcPtr = ProcPtr;
  93. PItemProcPtr = ProcPtr;
  94.  
  95. TPPrPort = ^TPrPort;
  96. TPrPort = RECORD
  97.     gPort: GrafPort;                    {The Printer's graf port.}
  98.     gProcs: QDProcs;                    {..and its procs}
  99.     lGParam1: LONGINT;                  {16 bytes for private parameter storage.}
  100.     lGParam2: LONGINT;
  101.     lGParam3: LONGINT;
  102.     lGParam4: LONGINT;
  103.     fOurPtr: BOOLEAN;                   {Whether the PrPort allocation was done by us.}
  104.     fOurBits: BOOLEAN;                  {Whether the BitMap allocation was done by us.}
  105.     END;
  106.  
  107. { Printing Graf Port. All printer imaging, whether spooling, banding, etc, happens "thru" a GrafPort.
  108.   This is the "PrPeek" record.}
  109. TPPrInfo = ^TPrInfo;
  110. TPrInfo = RECORD
  111.     iDev: INTEGER;                      {Font mgr/QuickDraw device code}
  112.     iVRes: INTEGER;                     {Resolution of device, in device coordinates}
  113.     iHRes: INTEGER;                     {..note: V before H => compatable with Point.}
  114.     rPage: Rect;                        {The page (printable) rectangle in device coordinates.}
  115.     END;
  116.  
  117. { Print Info Record: The parameters needed for page composition. }
  118. TPPrStl = ^TPrStl;
  119. TPrStl = RECORD
  120.     wDev: INTEGER;
  121.     iPageV: INTEGER;
  122.     iPageH: INTEGER;
  123.     bPort: SignedByte;
  124.     feed: TFeed;
  125.     END;
  126.  
  127. TPPrXInfo = ^TPrXInfo;
  128. TPrXInfo = RECORD
  129.     iRowBytes: INTEGER;
  130.     iBandV: INTEGER;
  131.     iBandH: INTEGER;
  132.     iDevBytes: INTEGER;
  133.     iBands: INTEGER;
  134.     bPatScale: SignedByte;
  135.     bUlThick: SignedByte;
  136.     bUlOffset: SignedByte;
  137.     bUlShadow: SignedByte;
  138.     scan: TScan;
  139.     bXInfoX: SignedByte;
  140.     END;
  141.  
  142. TPPrJob = ^TPrJob;
  143. TPrJob = RECORD
  144.     iFstPage: INTEGER;                  {Page Range.}
  145.     iLstPage: INTEGER;
  146.     iCopies: INTEGER;                   {No. copies.}
  147.     bJDocLoop: SignedByte;              {The Doc style: Draft, Spool, .., and ..}
  148.     fFromUsr: BOOLEAN;                  {Printing from an User's App (not PrApp) flag}
  149.     pIdleProc: PrIdleProcPtr;           {The Proc called while waiting on IO etc.}
  150.     pFileName: StringPtr;               {Spool File Name: NIL for default.}
  151.     iFileVol: INTEGER;                  {Spool File vol, set to 0 initially}
  152.     bFileVers: SignedByte;              {Spool File version, set to 0 initially}
  153.     bJobX: SignedByte;                  {An eXtra byte.}
  154.     END;
  155.  
  156. { Print Job: Print "form" for a single print request. }
  157. TPPrint = ^TPrint;
  158. THPrint = ^TPPrint;
  159. TPrint = RECORD
  160.     iPrVersion: INTEGER;                {(2) Printing software version}
  161.     prInfo: TPrInfo;                    {(14) the PrInfo data associated with the current style.}
  162.     rPaper: Rect;                       {(8) The paper rectangle [offset from rPage]}
  163.     prStl: TPrStl;                      {(8)  This print request's style.}
  164.     prInfoPT: TPrInfo;                  {(14)  Print Time Imaging metrics}
  165.     prXInfo: TPrXInfo;                  {(16)  Print-time (expanded) Print info record.}
  166.     prJob: TPrJob;                      {(20) The Print Job request (82)  Total of the above; 120-82 = 38 bytes needed to fill 120}
  167.     printX: ARRAY [1..19] OF INTEGER;   {Spare to fill to 120 bytes!}
  168.     END;
  169.  
  170. { The universal 120 byte printing record }
  171. TPPrStatus = ^TPrStatus;
  172. TPrStatus = RECORD
  173.     iTotPages: INTEGER;                 {Total pages in Print File.}
  174.     iCurPage: INTEGER;                  {Current page number}
  175.     iTotCopies: INTEGER;                {Total copies requested}
  176.     iCurCopy: INTEGER;                  {Current copy number}
  177.     iTotBands: INTEGER;                 {Total bands per page.}
  178.     iCurBand: INTEGER;                  {Current band number}
  179.     fPgDirty: BOOLEAN;                  {True if current page has been written to.}
  180.     fImaging: BOOLEAN;                  {Set while in band's DrawPic call.}
  181.     hPrint: THPrint;                    {Handle to the active Printer record}
  182.     pPrPort: TPPrPort;                  {Ptr to the active PrPort}
  183.     hPic: PicHandle;                    {Handle to the active Picture}
  184.     END;
  185.  
  186. { Print Status: Print information during printing. }
  187. TPPfPgDir = ^TPfPgDir;
  188. THPfPgDir = ^TPPfPgDir;
  189. TPfPgDir = RECORD
  190.     iPages: INTEGER;
  191.     iPgPos: ARRAY [0..128] OF LONGINT;  {ARRAY [0..iPfMaxPgs] OF LONGINT}
  192.     END;
  193.  
  194. { PicFile = a TPfHeader followed by n QuickDraw Pics (whose PicSize is invalid!) }
  195. TPPrDlg = ^TPrDlg;
  196. TPrDlg = RECORD
  197.     Dlg: DialogRecord;                  {The Dialog window}
  198.     pFltrProc: ModalFilterProcPtr;      {The Filter Proc.}
  199.     pItemProc: PItemProcPtr;            {The Item evaluating proc.}
  200.     hPrintUsr: THPrint;                 {The user's print record.}
  201.     fDoIt: BOOLEAN;
  202.     fDone: BOOLEAN;
  203.     lUser1: LONGINT;                    {Four longs for user's to hang global data.}
  204.     lUser2: LONGINT;                    {...Plus more stuff needed by the particular printing dialog.}
  205.     lUser3: LONGINT;
  206.     lUser4: LONGINT;
  207.     END;
  208.  
  209.  
  210. PDlgInitProcPtr = ProcPtr;
  211.  
  212. TGnlData = RECORD
  213.     iOpCode: INTEGER;
  214.     iError: INTEGER;
  215.     lReserved: LONGINT;                 {more fields here depending on call}
  216.     END;
  217.  
  218. TRslRg = RECORD
  219.     iMin: INTEGER;
  220.     iMax: INTEGER;
  221.     END;
  222.  
  223. TRslRec = RECORD
  224.     iXRsl: INTEGER;
  225.     iYRsl: INTEGER;
  226.     END;
  227.  
  228. TGetRslBlk = RECORD
  229.     iOpCode: INTEGER;
  230.     iError: INTEGER;
  231.     lReserved: LONGINT;
  232.     iRgType: INTEGER;
  233.     xRslRg: TRslRg;
  234.     yRslRg: TRslRg;
  235.     iRslRecCnt: INTEGER;
  236.     rgRslRec: ARRAY [1..27] OF TRslRec;
  237.     END;
  238.  
  239. TSetRslBlk = RECORD
  240.     iOpCode: INTEGER;
  241.     iError: INTEGER;
  242.     lReserved: LONGINT;
  243.     hPrint: THPrint;
  244.     iXRsl: INTEGER;
  245.     iYRsl: INTEGER;
  246.     END;
  247.  
  248. TDftBitsBlk = RECORD
  249.     iOpCode: INTEGER;
  250.     iError: INTEGER;
  251.     lReserved: LONGINT;
  252.     hPrint: THPrint;
  253.     END;
  254.  
  255. TGetRotnBlk = RECORD
  256.     iOpCode: INTEGER;
  257.     iError: INTEGER;
  258.     lReserved: LONGINT;
  259.     hPrint: THPrint;
  260.     fLandscape: BOOLEAN;
  261.     bXtra: SignedByte;
  262.     END;
  263.  
  264. TPBitMap = ^BitMap;                     { A BitMap Ptr }
  265.  
  266. TN = 0..15;                             { a Nibble }
  267.  
  268. TPWord = ^TWord;
  269. THWord = ^TPWord;
  270. TWord = PACKED RECORD
  271.     CASE INTEGER OF
  272.       0:
  273.         (c1,c0: CHAR);
  274.       1:
  275.         (b1,b0: SignedByte);
  276.       2:
  277.         (usb1,usb0: Byte);
  278.       3:
  279.         (n3,n2,n1,n0: TN);
  280.       4:
  281.         (f15,f14,f13,f12,f11,f10,f9,f8,f7,f6,f5,f4,f3,f2,f1,f0: BOOLEAN);
  282.       5:
  283.         (i0: INTEGER);
  284.     END;
  285.  
  286. TPLong = ^TLong;
  287. THLong = ^TPLong;
  288. TLong = RECORD
  289.     CASE INTEGER OF
  290.       0:
  291.         (w1,w0: TWord);
  292.       1:
  293.         (b1,b0: LONGINT);
  294.       2:
  295.         (p0: Ptr);
  296.       3:
  297.         (h0: Handle);
  298.       4:
  299.         (pt: Point);
  300.     END;
  301.  
  302.  
  303. PROCEDURE PrPurge;
  304. PROCEDURE PrNoPurge;
  305. PROCEDURE PrOpen;
  306. PROCEDURE PrClose;
  307. PROCEDURE PrintDefault(hPrint: THPrint);
  308. FUNCTION PrValidate(hPrint: THPrint): BOOLEAN;
  309. FUNCTION PrStlDialog(hPrint: THPrint): BOOLEAN;
  310. FUNCTION PrJobDialog(hPrint: THPrint): BOOLEAN;
  311. FUNCTION PrStlInit(hPrint: THPrint): TPPrDlg;
  312. FUNCTION PrJobInit(hPrint: THPrint): TPPrDlg;
  313. PROCEDURE PrJobMerge(hPrintSrc: THPrint;hPrintDst: THPrint);
  314. FUNCTION PrDlgMain(hPrint: THPrint;pDlgInit: PDlgInitProcPtr): BOOLEAN;
  315. FUNCTION PrOpenDoc(hPrint: THPrint;pPrPort: TPPrPort;pIOBuf: Ptr): TPPrPort;
  316. PROCEDURE PrCloseDoc(pPrPort: TPPrPort);
  317. PROCEDURE PrOpenPage(pPrPort: TPPrPort;pPageFrame: TPRect);
  318. PROCEDURE PrClosePage(pPrPort: TPPrPort);
  319. PROCEDURE PrPicFile(hPrint: THPrint;pPrPort: TPPrPort;pIOBuf: Ptr;pDevBuf: Ptr;
  320.     VAR prStatus: TPrStatus);
  321. FUNCTION PrError: INTEGER;
  322. PROCEDURE PrSetError(iErr: INTEGER);
  323. PROCEDURE PrGeneral(pData: Ptr);
  324. PROCEDURE PrDrvrOpen;
  325. PROCEDURE PrDrvrClose;
  326. PROCEDURE PrCtlCall(iWhichCtl: INTEGER;lParam1: LONGINT;lParam2: LONGINT;
  327.     lParam3: LONGINT);
  328. FUNCTION PrDrvrDCE: Handle;
  329. FUNCTION PrDrvrVers: INTEGER;
  330.  
  331.  
  332.     { UsingPrinting }
  333.  
  334.  
  335.     IMPLEMENTATION
  336. END.
  337.  
  338.  
  339.